package com.example.pages;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.FindBys;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: kzv
 * Date: 27.02.13
 * Time: 13:16
 * To change this template use File | Settings | File Templates.
 */
public class MovieListPage extends InternalPage {

    @FindBy(xpath = "//img[@title=\"Add movie\"]")
    public WebElement addMovieButton;

    @FindBys(@FindBy(xpath = "//*[@id=\"results\"]/descendant::div[@class=\"title\"]"))
    List<WebElement> linksToFilms;

    public Boolean isOnMovieListPage() {
        return addMovieButton.isDisplayed();
    }

    public void movieOpen(String moviename){
        for(WebElement link : linksToFilms){
            if(link.getText().equals(moviename)){
                link.click();
                break;
            }
        }
    }

}
